package com.hxc.controller;

import com.hxc.pojo.Cartiy;
import com.hxc.service.CartigyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("cartigy")
public class CartigyController {

    @Autowired
    private CartigyService cartigyService;

    @RequestMapping("findAll")
    public String findAll(Model model){
        List<Cartiy> cartiys=cartigyService.findAll();
        model.addAttribute("cartiys",cartiys);
        return "/WEB-INF/jsp/cartigyList.jsp";
    }

    @RequestMapping("delete")
    public String delete(Integer id){
        cartigyService.delete(id);
        return "/cartigy/findAll.html";
    }

    @RequestMapping("addCartiy")
    public String addCartiy(){
        return "/WEB-INF/jsp/addCartiy.jsp";
    }

    @RequestMapping("save")
    public String save(Cartiy cartiy){
        cartigyService.save(cartiy);
        return "/cartigy/findAll.html";
    }

}
